using System;
using System.Configuration;

namespace ClickOnceMaster.WizardConfiguration
{
    /// <summary>
    /// Represents a configuration element for manifest configuration settings.
    /// </summary>
    internal class ManifestSettings : ConfigurationElement
    {
        #region Instance events

        ///<summary>
        ///Occurs when the <see cref="SourceFilesPath"/> property value changes.
        ///</summary>
        public event EventHandler SourceFilesPathChanged;

        #endregion

        #region Instance properties

        /// <summary>
        /// Gets or sets the path to adding files.
        /// </summary>
        [ConfigurationProperty("filesPath", DefaultValue = null)]
        public string FilesPath
        {
            get
            {
                return (string)this["filesPath"];
            }
            set
            {
                this["filesPath"] = value;
            }
        }

        /// <summary>
        /// Gets or sets the path to key file.
        /// </summary>
        [ConfigurationProperty("keyPath", DefaultValue = null)]
        public string KeyPath
        {
            get
            {
                return (string)this["keyPath"];
            }
            set
            {
                this["keyPath"] = value;
            }
        }

        /// <summary>
        /// Gets or sets the password for key file.
        /// </summary>
        [ConfigurationProperty("keyPassword")]
        public string KeyPassword
        {
            get
            {
                return (string)this["keyPassword"];
            }
            set
            {
                this["keyPassword"] = value;
            }
        }

        /// <summary>
        /// Source folder.
        /// </summary>
        [ConfigurationProperty("sourceFilesPath", DefaultValue = null)]
        public string SourceFilesPath
        {
            get
            {
                return (string)this["sourceFilesPath"];
            }
            set
            {
                if (this["sourceFilesPath"] != value)
                {
                    this["sourceFilesPath"] = value;
                    RaiseSourceFilesPathChanged(EventArgs.Empty);
                }
            }
        }

        /// <summary>
        /// Destination folder.
        /// </summary>
        [ConfigurationProperty("destinationFilesPath", DefaultValue = null)]
        public string DestinationFilesPath
        {
            get
            {
                return (string)this["destinationFilesPath"];
            }
            set
            {
                this["destinationFilesPath"] = value;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        [ConfigurationProperty("primaryNumber", DefaultValue = 1)]
        public int PrimaryNumber
        {
            get
            {
                return (int)this["primaryNumber"];
            }
            set
            {
                this["primaryNumber"] = value;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        [ConfigurationProperty("additionalNumber", DefaultValue = 0)]
        public int AdditionalNumber
        {
            get
            {
                return (int)this["additionalNumber"];
            }
            set
            {
                this["additionalNumber"] = value;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        [ConfigurationProperty("constructionNumber", DefaultValue = 0)]
        public int ConstructionNumber
        {
            get
            {
                return (int)this["constructionNumber"];
            }
            set
            {
                this["constructionNumber"] = value;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        [ConfigurationProperty("releaseNumber", DefaultValue = 0)]
        public int ReleaseNumber
        {
            get
            {
                return (int)this["releaseNumber"];
            }
            set
            {
                this["releaseNumber"] = value;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        [ConfigurationProperty("applicationName")]
        public string ApplicationName
        {
            get
            {
                return (string)this["applicationName"];
            }
            set
            {
                this["applicationName"] = value;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        [ConfigurationProperty("applicationPublisher")]
        public string ApplicationPublisher
        {
            get
            {
                return (string)this["applicationPublisher"];
            }
            set
            {
                this["applicationPublisher"] = value;
            }
        }

        #endregion

        #region Instance methods

        /// <summary>
        /// Calls the <see cref="SourceFilesPathChanged"/> event.
        /// </summary>
        private void RaiseSourceFilesPathChanged(EventArgs e)
        {
            EventHandler handler = SourceFilesPathChanged;
            if (handler != null) handler(this, e);
        }

        #endregion
    }
}